package 设计模式.结构型.Flyweight享元.池化.对象池;

/**
 * @author 张从龙
 * @version [1.0.0, 2022/8/15]
 */
public class Client {
    public static void main(String[] args) throws Exception {
        //创建对象池
        ObjectPool<User> objectPool = new ObjectPool(User.class, 10);

        //从对象池中取对象
        User user = objectPool.get();
        User user2 = objectPool.get();

        System.out.println(user.hashCode());
        System.out.println(user2.hashCode());

        user.setId(1);
        user.setName("张从龙");
        System.out.println(user.toString());

        objectPool.recycle(user);
    }
}
